package utils
{
	 
	import flash.events.Event;
	import vo.ROFactory;
	import mx.collections.ArrayCollection;
	import mx.rpc.remoting.RemoteObject;
	import mx.rpc.events.ResultEvent;
	import mx.core.Application;
	import mx.controls.Alert;
	import vo.ModelLocator;
	import vo.GmGameStore;
	
	public class DoSearchEvent extends Event 
	{ 
		
		 
	public var GameName:String=""; 
	public var ServerType:String="";
	public var Area:String="";
	public var Unit:String="";
	
	public function DoSearchEvent(gameName:String,serverType:String,area:String,unit:String) 
	{ 
		super("DoSearch",false); 
		GameName= gameName; 
		ServerType =serverType; 
		Area =area;
		Unit =unit;
	}

	
	public function Filter(list:ArrayCollection):ArrayCollection 
	{ 
		var newlist:ArrayCollection = new ArrayCollection(); 			
		/* Alert.show(GameName+"-"+ServerType+"-"+Area+"-"+Unit); */ 
		/* var gamenamero:RemoteObject=ROFactory.getInstance().getGameRemoteObject();
	 	gamenamero.removeEventListener(ResultEvent.RESULT,gameName_resultHandler);
	 	gamenamero.addEventListener(ResultEvent.RESULT,gameName_resultHandler);
	 	gamenamero.getGameDetial(GameName);
				
		var gamedetialro:RemoteObject=ROFactory.getInstance().getGameStoreRemoteObject();
     	gamedetialro.removeEventListener(ResultEvent.RESULT,gameDetial_resultHandler);
     	gamedetialro.addEventListener(ResultEvent.RESULT,gameDetial_resultHandler);
     	/* gamedetialro.addEventListener(FaultEvent.FAULT,gameDetial_faultHandler); 
     	gamedetialro.getLoginGameDetialData(GameName,ServerType,Area,Unit);	
	 */
		return newlist; 

	} 
	/* public function gameDetial_resultHandler(event:ResultEvent):void{
              	if(event.result!=null){
	 		    	if(event.result is ArrayCollection){   		    				
	 		    		Application.application.gameDetial.gmdetialData=event.result as ArrayCollection;
	 		    		/* Application.application.webViews.selectedChild=Application.application.gameDetial; 
	 		    	} 
	 		    	else{
	        				Alert.show("未找到相关数据！");
	        			}
              	}
              	else{
              		Alert.show("未找到相关数据！");
              	}
 		    }
	public function gameName_resultHandler(event:ResultEvent):void{
             	if(event.result is ArrayCollection){
            			ModelLocator.getInstance().selectedGame=event.result as ArrayCollection;
            			if(ModelLocator.getInstance().selectedGame.length>0){
            			Application.application.gameDetial.gameName=ModelLocator.getInstance().selectedGame[0].gmGame.gameName; 
            			Application.application.gameDetial.firstListData.removeAll();
            			var gameTemp:String="";
            			for(var i:int;i<ModelLocator.getInstance().selectedGame.length;i++){
            				var gcs:GmGameStore=GmGameStore(ModelLocator.getInstance().selectedGame[i]);
            				if(gameTemp.indexOf(gcs.gmCserver.cserverName)==-1){
		      						gameTemp=gameTemp+gcs.gmCserver.cserverName;
		      						Application.application.gameDetial.firstListData.addItem(gcs);
		      					} 
            			}
        			}
        			else{
        				Alert.show("未找到相关数据！");
        			}
        		}
             } */
 }

}